#ifndef BASE_CRC32_H_
#define BASE_CRC32_H_

#include <string>

#include "basictypes.h"

namespace base {

	// Updates a CRC32 checksum with |len| bytes from |buf|. |initial| holds the
	// checksum result from the previous update; for the first call, it should be 0.
	uint32 UpdateCrc32(uint32 initial, const void* buf, size_t len);

	// Computes a CRC32 checksum using |len| bytes from |buf|.
	inline uint32 ComputeCrc32(const void* buf, size_t len) {
		return UpdateCrc32(0, buf, len);
	}
	inline uint32 ComputeCrc32(const std::string& str) {
		return ComputeCrc32(str.c_str(), str.size());
	}

}  // namespace base

#endif  // BASE_CRC32_H_